const state = {
	noticeShow: false,
	widgetShow: false,
	startMenuShow: false,
	dateBoxShow: false,
	currentPag: 'start'
}

const mutations = {
	//关闭所有悬浮的面板
	CLOSE_ALL_PANEL(state, val) {
		state.widgetShow = val
		state.noticeShow = val
		state.startMenuShow = val
		state.dateBoxShow=val
	},
	// 小工具显示/隐藏
	WIDGET_SHOW(state,val){
		state.widgetShow = val
	},
	//通知中心
	NOTICE_SHOW(state, val) {
		state.noticeShow = val
	},
	//通知中心
	STARTMENU_SHOW(state, val) {
		state.startMenuShow = val
	},
	// 开始菜单弹窗显示/隐藏控制
	STARTMAP_SHOW(state, val) {
		if (val === 'startMenu' || val === 'startMenuImg' || val === 'search' || val === 'searchImg') {
			if (state.startMenuShow) {
				if (val.indexOf(state.currentPag) > -1) {
					state.startMenuShow = false
				} else {
					state.currentPag = val.slice(0, 4)
				}
				return
			}
			if (!state.startMenuShow) {
				state.startMenuShow = true
				state.currentPag = val.slice(0, 4)
			}
			return
		}
		if (val === 'taskbar') return
		state.startMenuShow = false
	},
	// 日期窗口显示/隐藏
	DATEBOX_SHOW(state,val){
		state.dateBoxShow=val
	}
}

const actions = {
	closeAllPanel({ commit }, val) {
		commit('CLOSE_ALL_PANEL', val)
	},
	changeNoticeShow({ commit }, val) {
		commit('NOTICE_SHOW', val)
	},
	changeWidgetShow({ commit }, val) {
		commit('WIDGET_SHOW',val)
	},
	changeStartMenuShow({ commit }, val) {
		commit('STARTMENU_SHOW', val)
	},
	changeDateBoxShow({commit},val){
		commit('DATEBOX_SHOW',val)
	}
}

export default {
	namespaced: true,
	state,
	mutations,
	actions
}